Recently due to project needs, need to self-control a watch view, and add some business logic, so according to customize a view of the steps, made a clock, see:Here is my custom view code, referring to the online god code, I did some of the business logic of the project, optimized the whole view.Package Com.hp.clock;import Android.content.broadcastreceiver;import Android.content.context;import Android.content.intent;import Android.content.intentfilter;import Android.content.res.typedarray;import
*/ private int secondwidth;There are so many variables.2. About the construction methodAs you can see, when I inherit the view, the system asks me to implement its construction method, there are four main construction methods, as follows:1.Public Clockview (Context context)The construction method is called when I am new to a view in the Java code.2.Public Clockview (context context, AttributeSet attrs)T
performed on the Canvas after the save operation from affecting subsequent painting. Save and restore must be used together (restore can be less than save, but not more). If the restore calls more than save, an Error is thrown.
7. Draw text on the specified path using drawTextOnPath. 3. Code
Package com. example. canvastest. view; import java. util. calendar; import android. content. context; import android. graphics. canvas; import android. graphics. color; import android. graphics. paint; imp
hand turns how many degrees #define PREMINUTEA 6 How much is the hour clockwise #define Prehoura 30//minute clockwise turn how many degrees #define Prehourminute 0.5//second minutes of the minute turn #define Preminutesecond 0.1 #defi Ne Angle2raditon (a) ((a)/180.0 * m_pi) #import "ViewController.h" @interface Viewcontroller () @property (weak, Nona
Tomic) Iboutlet Uiimageview *clockview;
/** Second Hand * * @property (nonatomic, strong) Calayer
Let's look at the final effect.
Start to implementCreate a new Clockview integrated view
public class Clockview extends View {
}
Rewrite the Onmeasure method first, here to say the view measurement mode, a total of three kinds: 1, exactly
That is, the exact value pattern, when we specify the Layout_width property or Layout_height property of the control as a specific value, such as a
the clock frequency and manage the system time accordingly.
With the clock speed, you only need to sync the NTP server once in a while, and this occasional time can even be once a year.
First, download the clock speed from the network, compile and install. Then, use the Sntpclock tool to see the difference between the remote clock and the local clock, as shown below. (Use the IP address of the remote NTP server instead of 1.2.3.4).
# Sntpclock 1.2.3.4 |
Linux, the commands for clock viewing and setting are mainly date, hwclock, and clock. Among them, clock and hwclock usage is similar, only use one on the line, except that the clock command supports the Alpha hardware system in addition to the x86 hardware system.
1. DateView system time# dateSet system time# date--set "07/07/06 10:19" (Month/day/year: minutes: SEC)2, Hwclock/clockView hardware Time# Hwclock--showOr# clock--showSet Hardware time# Hw
Linux system time is sometimes not synchronized with hardware timeLinux Clock is divided into System Clock and Real Time Clock (RTC. The system clock is the current Linux Kernel clock, and the hardware clock is the battery-powered clock on the motherboard. This hardware clock can be set in the BIOS. When Linux is started, the hardware clock reads the system clock settings, and then the system clock runs independently of the hardware.All commands (including functions) in Linux use the system cloc
| cut-f2-d:
Cat/etc/sysconfig/selinuxView the ip address and Mac address of the server NIC
In the ifcfg-eth0 file you can see mac, Gateway and other information.
Ifconfig
Cat/etc/sysconfig/network-scripts/ifcfg-eth0 | grep IPADDR
Cat/etc/sysconfig/network-scripts/ifcfg-eth0 | grep IPADDR | cut-f2-d =
Ifconfig eth0 | grep "inet addr:" | awk '{print $2}' | cut-c 6-
Ifconfig | grep 'inet addr: '| grep-v' 127. 0.0.1' | cut-d:-f2 | awk '{print $1 }'View default server gateways
Cat/etc/sysconfig/netw
server for your network, it cannot generate more traffic than you expected.
Another option is the D. J. Bernstein clock speed program. It can not only update the system clock from the NTP server, but also calculate the clock frequency and manage the system time accordingly.
With clock speed, you only need to occasionally synchronize the NTP server after the initial configuration; this occasional time can even be once a year.
First, download the clock speed from the network for compilat
. J. Bernstein clock speed program. It can not only update the system clock from the NTP server, but also calculate the clock frequency and manage the system time accordingly.
With clock speed, you only need to occasionally synchronize the NTP server after the initial configuration; this occasional time can even be once a year.
First, download the clock speed from the network for compilation and installation. Then, use the sntpclock tool to view the differences between the remote clock and t
) /255.0; CGFloat b= Arc4random_uniform ( the) /255.0; return[Uicolor colorwithred:r green:g blue:b Alpha:1];}The practice of the clock--the difficulty is to get the current time by Nscalendar1 #import "ViewController.h"2 //calculates the angle at which the second hand turns over by the number of seconds3 #defineSecondrotation (second) ((second * 6)/180.0 * M_PI)4 //calculates the angle at which the minute hand turns through fractions5 #defineMinuterotation (minute) ((minute * 6)/180.0 * M_PI)6
file you can see mac, Gateway and other information.
Ifconfig
Cat/etc/sysconfig/network-scripts/ifcfg-eth0 | grep IPADDR
Cat/etc/sysconfig/network-scripts/ifcfg-eth0 | grep IPADDR | cut-f2-d =
Ifconfig eth0 | grep "inet addr:" | awk '{print $2}' | cut-c 6-
Ifconfig | grep 'inet addr: '| grep-V' 127. 0.0.1' | cut-d:-f2 | awk '{print $1 }'View default server gateways
Cat/etc/sysconfig/networkView the default DNS of the server
Cat/etc/resolv. confView default server Language
Echo $ LANG $ LANGUAGE
./test. Sh515 12483 21734 0 00:00:00 pts/12 grep Test$ Screen-DMs screen_test$ Screen-listThere is a screen on:27963. screen_test (detached)1 socket in/tmp/uscreens/S-Jiangfeng.$ Screen-r screen_test7. nohup Program Output to nohup. Out by default. You can set it by yourself: nohup test. Sh> test. log
8. DateView System Time:# DateSet system time# Date -- set "07/07/06" (month/day/year hour: minute: second)9. hwclock/clockView hardware time# Hwclock
servers at NIST, China National Timing Center and China Education Network are at this level. Stratum = 2 of the NTP server is synchronized with the stratum = 1 server, the performance is slightly worse, but the accuracy is also in the order of milliseconds, so there is no difference. Next to each synchronization level, Stratum adds one.Windows 2000 starts with a service that automatically synchronizes time. On Windows XP, the open time setting has a network pair setting. The default is once per
good enough. Below is an example under Fedora. Configuration:# grep "^server"/etc/ntp.confServer 0.pool.ntp.orgServer 1.pool.ntp.orgServer 2.pool.ntp.orgServer pool.ntp.orgServer 127.127.1.0 # Local clockView status after starting NTPD# NTPQ-PNRemote refID St T when poll reach delay offset jitter==============================================================================64.25.87.54 128.118.25.5 2 U 10 64 17 79.194-542.89 1.94264.72.116.51 129.7.1.6
represents the system time, i.e. the system clock is synchronized with the hardware clocksystem clock and Hardware clock synchronization:# Hwclock--SYSTOHC or # clock--SYSTOHC synchronize hardware clock with system clockView TimeMethod/Step 2
Time zone settings:To start setting the time zone, refer to the information on the Internet, using the Tzselect command, and found that the Tzselect command only tells the way to set the time zone, not
1. Overview
This article is mainly about how to customize a time clock, through simple exercises can be a simple study of Android in the custom view of some of the common drawing techniques to optimize the Android graphics operation. To start with, look at the effect we need to achieve:
When we see this effect there should be some thinking in mind, we should break it down into the following steps:1. Instrument panel (Round)2, tick marks (long medium short)3, tick value (1-12)4. Pointer (time
Contact Us
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.